<?php
class Blog_Form_PostForm extends Zend_Form
{
    public function init()
    {
        $this->setMethod('post');

        $blogPost = new Blog_Model_Post();

        $title_definition = $blogPost->getTable()->getColumnDefinition('title');
        $this->addElement('text', 'title', array(
            'label'      => 'blog post title',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('validator' => 'StringLength',
                      'options' => array(0, $title_definition['length']))
            )
        ));

        $content_definition = $blogPost->getTable()->getColumnDefinition('content');
        $this->addElement('textarea', 'content', array(
            'label'      => 'blog post content',
            'required'   => true,
            'validators' => array(
                array('validator' => 'StringLength',
                      'options' => array(0, $content_definition['length']))
            )
        ));


        $this->addElement('submit', 'submit', array(
            'label'    => 'Save',
        ));
    }
}

